<?php
/**
 * Created by PhpStorm.
 * User: lin.zhonghuang
 * Date: 2017/9/12
 * Time: 18:45
 */
require __DIR__ . '/../../engine.inc';
$mongo = new  \inframe\library\Mongo([
    'host' => '127.0.0.1',
    'port' => 2017,
    'default' => 'inframe', # 默认数据库
]);

$collection = $mongo->database()->collection('default');

switch ($argv[1]) {
    case 'iterate':
        $collection->iterate(function ($data) {
            var_dump($data);
        });
        break;
    case 'insert':
        $res = $collection->insert([
            "title" => "MongoDB",
            "description" => "database",
            "likes" => 100,
            "url" => "http://www.runoob.com/mongodb/",
//            'time' => time(),
            "by", "菜鸟教程"
        ]);

        dumpout($res === null);
        break;
    case 'update':
        $res = $collection->update(['2'=>'------------------------------------------------------'],['title'=>'MongoDB']);
        dumpout($res);
        break;
}